package com.example.demo.mapper;

import com.example.demo.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface UserMapper {

    @Select("select * from user")
    List<User> findAll();
    @Update("insert into user(`username`,`password`)values(#{username},#{password})")
    @Transactional
     void add(User user);

//     // 新增方法定义
@Select("SELECT * FROM user WHERE username = #{username}")
User findByUsername(String username);
}
